home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1776 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.5 KB  |  52 lines

  1. Path: comma.rhein.de!serpens!not-for-mail
  2. From: mlelstv@serpens.rhein.de (Michael van Elst)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: Disk available?
  5. Date: 23 Jan 1996 14:48:43 +0100
  6. Organization: dis-
  7. Message-ID: <4e2ovr$5d3@serpens.rhein.de>
  8. References: <423.6596T796T2374@mailbox.swipnet.se>
  9. NNTP-Posting-Host: serpens.rhein.de
  10.  
  11. m-29431@mailbox.swipnet.se (Daniel Adolfsson) writes:
  12.  
  13. >What is the best way to find out whether there's a disk in a drive or not?
  14. >Just Lock()ing for example 'DF0:' won't work too good, since there might be
  15. >an unreadable (or a disk of another format, AFS, for example) disk in it,
  16. >in which case the Lock() will fail!
  17.  
  18. Send the handler process an ACTION_DISKINFO. It fills out an InfoData
  19. structure that contains an id_DiskType. The type ID_NO_DISK_PRESENT
  20. is returned when there is no disk in the drive.
  21.  
  22. #include <dos/dosextens.h>
  23. #include <proto/dos.h>
  24.  
  25. BOOL dos_disk_in_drive(STRPTR devname)
  26. {
  27.     struct DevProc *dvp;
  28.     __aligned struct InfoData ID;
  29.     
  30.     dvp = GetDeviceProc(devname, NULL);
  31.     if (dvp) {
  32.         DoPkt(dvp->dvp_Port, ACTION_DISK_INFO, MKBADDR(&ID), 0, 0, 0, 0);
  33.         FreeDeviceProc(dvp);
  34.         return (BOOL)(ID.id_DiskType != ID_NO_DISK_PRESENT);
  35.     }
  36.     return FALSE;
  37. }
  38.  
  39. void __main()
  40. {
  41.     if (dos_disk_in_drive("DF0:"))
  42.         Printf("disk inserted\n");
  43.     else
  44.         Printf("no disk inserted\n");
  45. }
  46.  
  47. -- 
  48.                                 Michael van Elst
  49.  
  50. Internet: mlelstv@serpens.rhein.de
  51.                                 "A potential Snark may lurk in every tree."
  52.